package com.company.clientscard.server.entityimport;

import java.io.File;
import java.util.Timer;
import java.util.TimerTask;

public class DocumentLoadTimer {
	Timer timer;

	public DocumentLoadTimer(int seconds) {

		timer = new Timer();
		timer.schedule(new LoadTask(), seconds * 1000, seconds * 1000);
		System.out.println("-------------------TIMER LOADED-----------------");
	}

	class LoadTask extends TimerTask {

		@Override
		public void run() {

			System.out.println("-------------------TIMER RAN-----------------");

			File baseDir = new File("D:\\java\\importToDb");

			File[] files = baseDir.listFiles();
			for (int i = 0; i <= files.length - 1; i++) {
				File file = files[i];
				if (!file.isDirectory()) {
					DocumentEntityImporter di = new DocumentEntityImporter(
							file.getName());

					file.delete();
				}
			}
		}
	}
}
